const Router = require('koa-router');
const {
    login,
    register,
    getUser,
    patchUser,
    verified,
    loginByPhone,
    bindPhone,
    validateCode,
    sendCode,
    bindEmail,
    sendEmailCode,
    forgetPassword,
    modifiedPassword,
    renewToken
} = require('../services/user');

const {
    addAddress,
    patchAddress,
    deleteAddress,
    queryAddressList,
    setDefaultAddr
 } = require('../services/user/address');

const router = new Router({
    prefix: '/user'
});

router.post('/login', login);
router.post('/register', register);
router.get('/', getUser);
router.patch('/', patchUser);
router.patch('/verified', verified);
router.post('/phone/login', loginByPhone);
router.patch('/phone/bind', bindPhone);
router.post('/phone/validate', validateCode);
router.post('/phone/send', sendCode);
router.patch('/email/bind', bindEmail);
router.post('/email/send', sendEmailCode);
router.patch('/forgetPassword', forgetPassword);
router.patch('/modifiedPassword', modifiedPassword);
router.get('/renew', renewToken);
router.post('/address', addAddress);
router.patch('/address', patchAddress);
router.delete('/address/:id', deleteAddress);
router.get('/address/list', queryAddressList);
router.get('/address/list', queryAddressList);
router.patch('/address/:id', setDefaultAddr);

module.exports = router;
